package mergeSort;

import java.util.Arrays;
import java.util.Random;

/**
 *  归并排序的测试
 */

public class TestMergeSort {
    public static void testMergeSort(int[] array) {
        //array = Arrays.copyOf(array,array.length);
        long startTime = System.currentTimeMillis();
        MyMergeSort.mergeSort(array);
        long endTime = System.currentTimeMillis();
        System.out.println("归并排序耗时:"+(endTime - startTime)+"ms");
        //System.out.println(Arrays.toString(array));
    }

    public static void main(String[] args) {
        int[] array = new int[1000_0000];
        //int[] array = {9,42,65,12,76,32,14,9,42,100,45};
        initArrayNotOrder(array); //无序初始化
        //initArrayOrder(array); //有序初始化
        testMergeSort(array);
        //System.out.println(Arrays.toString(array));
    }

    public static void initArrayOrder(int[] array) {
        //有序的初始化
        for (int i = 0; i < array.length; i++) {
            array[i] = i;
        }
    }
    public static void initArrayNotOrder(int[] array) {
        //不有序的初始化
        Random random = new Random();
        for (int i = 0; i < array.length; i++) {
            array[i] = random.nextInt(1_0000_0000);
        }
    }

}
